<?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use common\components\widgets\Datetimepicker;
Datetimepicker::widget(['timepicker' => 'true','format'=>'Y-m-d H:i']);
?>
<div class="yx-praise-box zx-min-height">
    <div class="yx-praise-list-box yx-praise-list-box1">
        <?php $form = ActiveForm::begin(['enableClientValidation' => false, 'enableAjaxValidation' => true, 'options' => ['class' => 'form-validate']]); ?>
        <table width="100%" class="table-form">
            <tr>
                <th class="zx-goods-table">课次单价</th>
                <td style="padding:6px 0;"><?=$data->price?></td>
            </tr>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['price_name']; ?></th>
                <td><?= $form->field($model, 'price_name', ['template' => '{input}{hint}{error}'])->textInput([ 'class' => 'input-text']) ?></td>
            </tr>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['activity_name']; ?></th>
                <td><?= $form->field($model, 'activity_name', ['template' => '{input}{hint}{error}'])->textInput([ 'class' => 'input-text']) ?></td>
            </tr>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['is_activity']; ?></th>
                <td><?= $form->field($model, 'is_activity', ['template' => '{input}{hint}{error}'])->radioList([1=>'是',0=>'否']) ?></td>
            </tr>
            <tbody id="activity_box" style="display: <?php if($model->is_activity == 1) { ?> <?php }else {?>none<?php } ?>">
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['activity_start_time']; ?></th>
                    <td><?= $form->field($model, 'activity_start_time', ['template' => '{input}{hint}{error}'])->textInput([ 'class' => 'datetimepicker input-text']) ?></td>
                </tr>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['activity_end_time']; ?></th>
                    <td><?= $form->field($model, 'activity_end_time', ['template' => '{input}{hint}{error}'])->textInput([ 'class' => 'datetimepicker input-text']) ?></td>
                </tr>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['effective_number']; ?></th>
                    <td><?= $form->field($model, 'effective_number', ['template' => '{input}{hint}{error}'])->textInput([ 'class' => 'input-text']) ?></td>
                </tr>
            </tbody>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['is_frequency']; ?></th>
                <td><?= $form->field($model, 'is_frequency', ['template' => '{input}{hint}{error}'])->radioList([1=>'是',0=>'否'], []) ?></td>
            </tr>
            <tbody id="frequency_box" style="display: <?php if($model->is_frequency == 1) { ?>none<?php }else {?><?php } ?>">
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['deadline_type']; ?></th>
                    <td style="display: inline-block;"><?= $form->field($model, 'deadline_type', ['template' => '{input}{hint}{error}'])->widget(\kartik\select2\Select2::className(),['data'=>['month'=>'月','year'=>'年'],'options' => ['placeholder' => '请选择']]) ?></td>
                </tr>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['deadline']; ?></th>
                    <td style="display: inline-block;"><?= $form->field($model, 'deadline', ['template' => '{input}{hint}{error}'])->widget(\kartik\select2\Select2::className(),['data'=>[1=>1,2=>2,3=>3,4=>4,5=>5,7=>7,8=>8,9=>9,10=>10],'options' => ['placeholder' => '请选择']]) ?></td>
                </tr>
            </tbody>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['lesson']; ?></th>
                <td><?= $form->field($model, 'lesson', ['template' => '{input}{hint}{error}'])->textInput([ 'class' => 'input-text']) ?></td>
            </tr>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['price']; ?></th>
                <td><?= $form->field($model, 'price', ['template' => '{input}{hint}{error}'])->textInput([ 'class' => 'input-text']) ?></td>
            </tr>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['market_price']; ?></th>
                <td><?= $form->field($model, 'market_price', ['template' => '{input}{hint}{error}'])->textInput([ 'class' => 'input-text']) ?></td>
            </tr>
            <tr>
                <th class="zx-goods-table">活动价</th>
                <td><?= $form->field($model, 'lesson_price', ['template' => '{input}{hint}{error}'])->textInput([ 'class' => 'input-text']) ?></td>
            </tr>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['distribution_way']; ?></th>
                <td style="display: inline-block;"><?= $form->field($model, 'distribution_way', ['template' => '{input}{hint}{error}'])->widget(\kartik\select2\Select2::className(),['data'=>[1=>'比例',0=>'固定'],'options' => ['placeholder' => '请选择']]) ?></td>
            </tr>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['distribution_proportion']; ?></th>
                <td><?= $form->field($model, 'distribution_proportion', ['template' => '{input}{hint}{error}'])->textInput([ 'class' => 'input-text'])->hint('分成方式是比例是（如：20% 填写20）') ?></td>
            </tr>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['subsidy_type']; ?></th>
                <td><?= $form->field($model, 'subsidy_type', ['template' => '{input}{hint}{error}'])->radioList([1=>'按学生',0=>'按课程'], []) ?></td>
            </tr>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['subsidy_money']; ?></th>
                <td><?= $form->field($model, 'subsidy_money', ['template' => '{input}{hint}{error}'])->textInput([ 'class' => 'input-text']) ?></td>
            </tr>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['is_scholarship']; ?></th>
                <td><?= $form->field($model, 'is_scholarship', ['template' => '{input}{hint}{error}'])->radioList([1=>'是',2=>'否'], []) ?></td>
            </tr>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['scholarship']; ?></th>
                <td><?= $form->field($model, 'scholarship', ['template' => '{input}{hint}{error}'])->textInput([ 'class' => 'input-text']) ?></td>
            </tr>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['status']; ?></th>
                <td><?= $form->field($model, 'status', ['template' => '{input}{hint}{error}'])->radioList([1=>'启用',0=>'禁用'], []) ?></td>
            </tr>
            <tr>
                <th class="zx-goods-table"><?= $model->attributeLabels()['back_status']; ?></th>
                <td><?= $form->field($model, 'back_status', ['template' => '{input}{hint}{error}'])->radioList([1=>'启用',0=>'禁用'], []) ?></td>
            </tr>
        </table>
        <div class="yx-submit-box">
            <?= Html::submitButton('提交', ['class' => "button yx-submit", 'id' => 'button']) ?>
        </div>
        <?php ActiveForm::end(); ?>
    </div>
</div>
<?php
$js = <<<JS
    $(document).on('change','input[name="GoodsPrice[is_activity]"]',function(){
         var vals = $(this).val();
         if(vals === '1'){
             $('#activity_box').css('display','');
         }else {
             $('#activity_box').css('display','none');
         }
    });
   $(document).on('change','input[name="GoodsPrice[is_frequency]"]',function(){
         var vals = $(this).val();
         if(vals === '1'){
             $('#frequency_box').css('display','none');
         }else {
             $('#frequency_box').css('display','');
         }
    });
JS;
$this->registerJS($js);
?>